package com.xinbochuang.machine.admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinbochuang.machine.admin.domain.AlarmCount;
import com.xinbochuang.machine.admin.domain.CameraInoutRecord;
import com.xinbochuang.machine.admin.mapper.CameraInoutRecordMapper;
import com.xinbochuang.machine.admin.service.ICameraInoutRecordService;
import com.xinbochuang.machine.common.utils.CustomDateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 杜文博
 * @date 2020-10-29
 */
@Service
public class CameraInoutRecordServiceImpl extends ServiceImpl<CameraInoutRecordMapper, CameraInoutRecord> implements ICameraInoutRecordService {

    @Resource
    CameraInoutRecordMapper cameraInoutRecordMapper;

    @Override
    public IPage<CameraInoutRecord> getCameraInoutListByCameraId(CameraInoutRecord cameraInoutRecord) {
        String cameraId = cameraInoutRecord.getCameraId();
        return cameraInoutRecordMapper.getCameraInoutByCameraId(new Page<>(cameraInoutRecord.getPageNum(), cameraInoutRecord.getPageSize()), cameraId);
    }

    /**
     * 今日出入数量统计
     *
     * @return 结果
     */
    @Override
    public int selectInoutCountToday() {
        return cameraInoutRecordMapper.selectInoutCountToday();
    }

    /**
     * 机房进出统计
     *
     * @param deptId 公司id
     * @return 结果
     */
    @Override
    public List<AlarmCount> inoutCount(int deptId) {
        return cameraInoutRecordMapper.selectInoutCount(deptId, CustomDateUtils.getThisWeekList());
    }
}
